#include "base.h"

#include <stdlib.h>
#include <stdio.h>

//---------- member method imp---------------
static void base_free(base_t * ptr){
    printf("base_free\n");
    free(ptr);
}
static int base_encrypted(base_t * ptr, char * src, char * dest){
    return ptr->value_;
}
static int base_get_value(base_t * ptr){
    return ptr->value_;
}
static void base_set_value(base_t * ptr, int value){
    ptr->value_ = value; 
}

void base_interface_init(base_t * ptr, cb_free_t free, cb_encrypted_t encrypted, cb_get_value_t get_value, cb_set_value_t set_value, int value){
    ptr->cb_free_ = free;
    ptr->cb_encrypted_ = encrypted;
    ptr->cb_get_value_ = get_value;
    ptr->cb_set_value_ = set_value;
    ptr->value_ = value;
}

//----------constructor ------------------
base_t * base_create(int value){
    base_t * ret =  (base_t*)malloc(sizeof(base_t));
    base_interface_init(ret, base_free, base_encrypted, base_get_value, base_set_value, value);
    return ret;
}
